const obj = {
  name:"jinge",
  age:18
}

const proxy = new Proxy(obj,{
  // 监听获取值
  get:function(target,key,receiver) {
    // target就是obj
    // receiver是代理的对象
    console.log(`监听到获取值的是${key}`,target);
    return target[key]
  },
  // 监听设置值
  set:function(target,key,newValue,receiver) {
    console.log(`我在设置${key}的值为${newValue}`,target);
    target[key] = newValue
  }
})

proxy.name = "jin"
console.log(proxy.name);